// pages/taskDetaily/taskDetaily.js
const app = getApp();
let taskId;
let type;
Page({
  /**
   * 页面的初始数据
   */
  data: {
    key:3
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let self = this;
    type = options.type;
    taskId = options.taskId;
    console.log(options);
    wx.request({
      url:app.globalData.prefix+"/taskAction/takeTaskInfo.do?taskId="+taskId+"&openId="+app.globalData.userInfo.openId,
      success:function(e){
        self.setData({task:e.data.result.task,take:e.data.result.take});
        let taskImage = e.data.result.task.taskImage;
        self.setData({imageArray:taskImage.split(';')});
      }
    });
  },

  giveUp(){
    wx.showModal({
      title:'提示',
      content:'确定放弃任务吗？',
      success:function(e){
        if(e.confirm){
          wx.request({
            url: app.globalData.prefix+'/taskAction/giveupTask.do?taskId='+taskId+"&openId="+app.globalData.userInfo.openId+"&type="+type,
            success:function(res){
              if(res.data.status!='00'){
                wx.$showToast(res.data.errorMsg);
                return;
              }
              wx.$showToast(res.data.result);
              if(type=="personal"){
                wx.navigateTo({
                  url: '../mySelfTask/mySelfTask',
                })
              }else if(type=="corps"){
                wx.navigateTo({
                  url: '../armyTask/armyTask',
                })
              }
            }
          })
        }
      }
    })
  },

})